package com.example.controller;

import com.alibaba.fastjson.JSON;
import com.example.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by zhengkai on 2017/1/22.
 */
@Controller
public class UserController {
    @Autowired
    private UserService userService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private PermissionService permissionService;

    @RequestMapping("/user/{id}")
    @ResponseBody
    public String userDetail(@PathVariable Integer id){
        return JSON.toJSONString(userService.userDetail(id));
    }

    @RequestMapping("/userinfo/{id}")
    @ResponseBody
    public String userinfo(@PathVariable Integer id){
        return JSON.toJSONString(userService.userinfo(id));
    }

    @RequestMapping("/role/{id}")
    @ResponseBody
    public String roleDetail(@PathVariable Integer id){
        return JSON.toJSONString(roleService.roleDetail(id));
    }

    @RequestMapping("/permission/{id}")
    @ResponseBody
    public String permissionDetail(@PathVariable Integer id){
        return JSON.toJSONString(permissionService.permissionDetail(id));
    }

    @RequestMapping("/userAdd")
    public String userAdd(){
        return "userAdd";
    }


    @RequestMapping("/userDelete")
    public String userDelete(){
        return "userDelete";
    }

    @RequestMapping("/403")
    public String error(){
        return "403";
    }
}
